package com.bysj.lms.controller;


import com.bysj.lms.common.ResultModel;
import com.bysj.lms.pojo.entity.LmsCheck;
import com.bysj.lms.pojo.entity.LmsFa;
import com.bysj.lms.service.ILmsCheckService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xiaojiakai
 * @since 2022-04-15
 */
@RestController
@RequestMapping("/lms-check")
@Api(tags = "检查管理")
public class LmsCheckController {

    @Autowired
    ILmsCheckService lmsCheckService;
    
    @ApiOperation(value = "检查模型")
    @GetMapping()
    public LmsCheck getModel(){
        return new LmsCheck();
    }
    
    @ApiOperation(value = "获取检查列表",notes = "检查类型输入：固定资产月检查M,低值半年检查HY,固定年底检查Y")
    @ApiImplicitParam(name = "type",value = "检查类型")
    @GetMapping("/getList")
    public ResultModel getMCList(Integer page,Integer count,String type){
        PageInfo checkList = lmsCheckService.getList(page,count,type);
        return ResultModel.success("查询成功",checkList);
    }
    
    @ApiOperation(value = "提交检查结果")
    @PutMapping("/check")
    public ResultModel check(@RequestBody LmsCheck lmsCheck){
        lmsCheck.setStatus("1");
        lmsCheck.setCheckTime(LocalDateTime.now());
        boolean check = lmsCheckService.updateById(lmsCheck);
        return check?ResultModel.success("提交成功"):ResultModel.failure("提交失败");
    }
}

